﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2.Util
{
    class DirUtil
    {
        public static void DelectDir(string srcPath)
        {
            try
            {
                DirectoryInfo dir = new DirectoryInfo(srcPath);
                FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();  //返回目录中所有文件和子目录
                foreach (FileSystemInfo i in fileinfo)
                {
                    if (i is DirectoryInfo)            //判断是否文件夹
                    {                       
                    }
                    else
                    {
                        try
                        {
                            File.Delete(i.FullName);      //删除指定文件
                        }catch(Exception ex)
                        {
                            continue;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                
            }
        }
    }
}
